package main

import (
	"fmt"
	"spider/common"
	"spider/fetcher"
	"spider/parse"
	"spider/models"
)

func main() {
	common.InitConfig("./conf.json")
	models.Connect();
	var header models.Header
	header=make(models.Header)

	header["Referer"]="https://bj.meituan.com/meishi/"

	header=common.MergreHeader(header,common.CommonHeader)

	req:= models.Request{
		Url:     "https://bj.meituan.com/meishi/pn5/",
		Header:  header,
		ReqFunc: fetcher.FetchGet,
		Parser:parse.ParseMeituanList,
		ParserName:"ParseMeituanList",
		DataFromParent:models.DataFromParent{"page":1,"cate":""},
	}
	fetchRes,err:=req.ReqFunc(req.Url,req.Header,req.PostData)
	if err==nil{
		pareRes,err:=req.Parser(fetchRes,req.DataFromParent)
		if err==nil{
			for _,v :=range pareRes.Requests{
				fmt.Printf("%+v\n",v)
			}

		}else{
			fmt.Println(pareRes)
		}
	}
}
